#ifndef ASYNCH_WRITE_QUEUE_H
#define ASYNCH_WRITE_QUEUE_H
#include "Task_Base/Task_Base.h"
#include <map>
using namespace std;

class CCriticalSection;

class Srv_Asynch_Man;
class Asynch_Write_Queue:public Task_Base
{
public:
    Asynch_Write_Queue(Srv_Asynch_Man *);
    virtual ~Asynch_Write_Queue(void);
public:
    void awq_add_service_handler(int client_socket);		//当连接到来
    void awq_append_write_buf(int client_socket,const char *pBuf,int nlen);//当数据到来
    void awq_post_send_socket(int client_socket);           //通知套接字可发送数据
    void awq_post_delete_socket(int client_socket);         //通知套接字安全删除

private:
    string* find_socket_write_buf(int client_socket);
    void    delete_service_handler(int client_socket);     //当连接结束
private:
    virtual int close();
    virtual int svc();//主动工作线程函数
private:
    Srv_Asynch_Man              *m_pAsynch_man;
    CCriticalSection            *m_poCriSection_write_buf;
    std::map<int,std::string*>	map_socket_write_buf;
    //std::map<int,int *>         map_socket_write_num;
    //std::map<int,int *>         map_socket_write_num2;
    std::map<int,int *>         map_socket_write_num3;
};

#endif // ASYNCH_WRITE_QUEUE_H
